provider "alicloud" {
  region = var.region
}

module "vpc" {
  source       = "store.cloudiac.org/idcos/vpc/alicloud"
  version      = "1.0.2"
  vpc_name     = var.vpc_name
  vpc_cidr     = var.vpc_cird_block
  vswitch_name = var.vswitch_name
  vswitch_cidr = var.vswitch_cird_block
}

module "securitygroup" {
  source               = "store.cloudiac.org/idcos/securitygroup/alicloud"
  version              = "1.0.0"
  security_name        = var.securitygroup_name
  security_description = var.security_description
  ip_protocol          = var.ip_protocol
  port_range           = var.port_range
  vpc_id               = module.vpc.vpc_id
}

resource "alicloud_kvstore_instance" "example" {
  db_instance_name  = var.db_instance_name
  vswitch_id        = module.vpc.vswitch_ids
  security_group_id = module.securitygroup.sgroup_id
  instance_type     = var.db_instance_type
  engine_version    = var.db_version
  zone_id           = module.vpc.availability_zone
  instance_class    = var.db_instance_class
  password          = var.password
  tags = {
    Created = var.db_tag_created,
    For     = var.db_tag_for,
  }
}